package xyz.herz.cts;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class UploadController {

    @GetMapping("/version")
    public String version(){
        return "1";
    }
    @PostMapping("/upload")
    public String upload(@RequestParam Map<String, String> formFields,
                         @RequestParam(required = false) MultipartFile file) {

        int paramCount = formFields.size();
        String msg = "接收到参数数：" + paramCount + ", 文件：" + (file != null ? file.getOriginalFilename() : "无");
        System.out.println(msg);
        return msg;
    }
}